package com.resign.carl.composite;

import com.resign.carl.composite.api.MenuComponent;
import com.resign.carl.composite.api.Waitress;
import com.resign.carl.composite.api.impl.Menu;
import com.resign.carl.composite.api.impl.MenuItem;

/**
 *
 * 组合模式
 * 用一个菜单例子来讲解(树形结构)
 * 用于数据个对象集合它们彼此之间有“整体/部分”的关系
 * Created by carl.zhao on 2016/6/16.
 */
public class Client {

    public static void main(String[] args) {
        MenuComponent pancakeHouseMenu = new Menu("PANCAKE HOUSE MENU", "Breakfast");
        MenuComponent dinerMenu = new Menu("DINER MENU", "Lunch");
        MenuComponent cafeMenu = new Menu("CAFE MENU", "Dinner");
        MenuComponent dessertMenu = new Menu("DESSERT MENU", "Dessert of course!");
        MenuComponent allMenus = new Menu("ALL MENUS", "All menus combined");

        allMenus.add(pancakeHouseMenu);
        allMenus.add(dinerMenu);
        allMenus.add(cafeMenu);
        dinerMenu.add(new MenuItem("Pasta", "Spaghetti with Marinara Sauce, and a slice of sourdough read", true, 3.89));
        dinerMenu.add(dessertMenu);
        dessertMenu.add(new MenuItem("Apple Pie", "Apple pie with a flake crust, topped with vanilla ice man", true, 1.59));
        Waitress waitress = new Waitress(allMenus);
        waitress.printMenu();
    }
}
